﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace XMLWithDatagrid
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                XmlDataDocument xmldata = new XmlDataDocument();
                xmldata.DataSet.ReadXml("xmlfile.xml");

                dataGridView1.DataSource = xmldata.DataSet;
                dataGridView1.DataMember = "Contact";

                MessageBox.Show("Okay");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        
    }
}
